package com.haidechizi.i18n.code.generator.common.message.file;

import com.haidechizi.i18n.code.generator.common.message.config.GeneratorProperties;
import com.haidechizi.i18n.code.generator.common.message.utils.ZipFileUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.UUID;

/**
 * @author wangdejun
 */
public class ZipFilePathResolver implements FilePathResolver {

    @Autowired
    private GeneratorProperties generatorProperties;

    /**
     * 处理器名称
     *
     * @return
     */
    @Override
    public String name() {
        return "zip";
    }

    @Override
    public String resolverPath(String filePath) {
        // 解压
        String i18nBasePath = generatorProperties.getI18nFileBasePath();
        String path = i18nBasePath + "/" + "unzipFile" + UUID.randomUUID();
        ZipFileUtils.unZipFiles(filePath, path);
        return path;
    }
}
